package test.io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * IO异常处理的练习
 * User: cp
 * Date: 2023-11-21
 * Time: 11:04
 */
public class IOclose {
    public static void main(String[] args) throws Exception {
        FileOutputStream out = null;
        try{
            out = new FileOutputStream("C:\\Javacode2\\a.txt");
            out.write(98);
            out.write(100);
        }catch (FileNotFoundException e){
            e.printStackTrace();
            System.out.println("处理文件找不到异常...");
        }catch(IOException e){
            e.printStackTrace();
            System.out.println("处理IO异常.....");
        }finally {
            if(null != out){
               try{
                   out.close();
               }catch(IOException e){
                   e.printStackTrace();
                   System.out.println("处理IO异常....");
               }finally {
                   out = null;
               }
            }
        }
    }
}
